<div class="layui-fluid" >
    <div class="layui-card">
        <div class="layui-card-body" style="padding: 15px;" >
            <form class="layui-form" id="userForm" lay-filter="userForm">
                    <div class="layui-fluid" style="padding-bottom: 75px;">
                        <div class="layui-card">
                            <div class="layui-card-header">${lang.get("TITLE_BASE_INFO","基本信息")}</div>
                            <div class="layui-card-body">
                                <div class="layui-form-item layui-row">
                                    <input name="userId" type="hidden"/>
                                    <div class="layui-inline layui-col-md12">
                                        <label class="layui-form-label">${lang.get("FIELD_ACCOUNT","基本信息")}<span style="color: red;">*</span></label>
                                        <div class="layui-input-block">
                                            <input name="account" placeholder="请输入账号" type="text" class="layui-input" lay-verify="required" required/>
                                        </div>
                                    </div>
                                    <div class="layui-inline layui-col-md12">
                                        <label class="layui-form-label">${lang.get("FIELD_NAME","姓名")}<span style="color: red;">*</span></label>
                                        <div class="layui-input-block">
                                            <input name="name" placeholder="请输入姓名" type="text" class="layui-input" lay-verify="required" required/>
                                        </div>
                                    </div>
                                    <div class="layui-inline layui-col-md12">
                                        <label class="layui-form-label">${lang.get("FIELD_BIRTHDAY","生日")}</label>
                                        <div class="layui-input-block">
                                            <input id="birthday" name="birthday" placeholder="请输入生日" type="text" class="layui-input date-icon" autocomplete="off"/>
                                        </div>
                                    </div>
                                    <div class="layui-inline layui-col-md6">
                                        <label class="layui-form-label">${lang.get("FIELD_PASSWORD","密码")}<span style="color: red;">*</span></label>
                                        <div class="layui-input-block">
                                            <input name="password" placeholder="请输入密码" type="password" class="layui-input" lay-verify="required|psw" autocomplete="new-password" required/>
                                        </div>
                                    </div>
                                    <div class="layui-inline layui-col-md6">
                                        <label class="layui-form-label">${lang.get("FIELD_REPEAT_PASSWORD","重复密码")}<span style="color: red;">*</span></label>
                                        <div class="layui-input-block">
                                            <input name="rePassword" placeholder="请输入重复密码" type="password" class="layui-input" autocomplete="new-password" lay-verify="required|repsw" required/>
                                        </div>
                                    </div>
                                    <div class="layui-inline layui-col-md12">
                                        <label class="layui-form-label">${lang.get("FIELD_EMAIL","邮件")}<span style="color: red;">*</span></label>
                                        <div class="layui-input-block">
                                            <input name="email" placeholder="请输入邮箱" type="text" class="layui-input" lay-verify="required|email" autocomplete="off" required/>
                                        </div>
                                    </div>
                                    <div class="layui-inline layui-col-md12">
                                        <label class="layui-form-label">${lang.get("FIELD_SEX","性别")}</label>
                                        <div class="layui-input-block">
                                            <input type="radio" name="sex" value="M" title="男" checked/>
                                            <input type="radio" name="sex" value="F" title="女"/>
                                        </div>
                                    </div>
                                    <div class="layui-inline layui-col-md12">
                                        <label class="layui-form-label">${lang.get("FIELD_PHONE","电话")}</label>
                                        <div class="layui-input-block">
                                            <input name="phone" placeholder="请输入电话" type="text" class="layui-input"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-card">
                            <div class="layui-card-header">${lang.get("TITLE_DUTY_INFO","职务信息")}</div>
                            <div class="layui-card-body">
                                <div class="layui-form-item layui-row">
                                    <div class="layui-inline layui-col-md12">
                                        <label class="layui-form-label">${lang.get("FIELD_DEPT","部门")}<span style="color: red;">*</span></label>
                                        <div class="layui-input-block">
                                            <input id="deptId" name="deptId" type="hidden">
                                            <input id="deptName" name="deptName" placeholder="请输入部门" type="text" class="layui-input" lay-verify="required" required autocomplete="off"/>
                                        </div>
                                    </div>
                                    <div class="layui-inline layui-col-md12">
                                        <label class="layui-form-label">${lang.get("FIELD_POST","职位")}<span style="color: red;">*</span></label>
                                        <div class="layui-input-block">
                                            <select name="position" xm-select="selPosition">
                                                <option value="">请选择职位</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group-bottom text-center" style="">
                        <a class="layui-btn" lay-filter="btnSubmit" lay-submit>&emsp;提交&emsp;</a>
                        <a type="reset" class="layui-btn layui-btn-primary" ew-event="closeDialog">&emsp;取消&emsp;</a>
                    </div>
            </form>
        </div>
    </div>
</div>

<script>
    var AddUser = function (index) {
        var admin = layui.admin,
            form = layui.form,
            $ =layui.jquery;
        //初始化
        this.init = function () {
            var roleNumber = 0;
            //初始化角色
            admin.get({
                api:'getRoleList',
                success:function (res) {
                    if(res.data) {
                        roleNumber = res.data.length;
                        var roleListHtml = [];
                        res.data.forEach(function (obj, index) {
                            roleListHtml.push('<input type="checkbox" name="roleIdList['+index+']" value="'+obj.roleId+'" title="'+obj.roleName+'">')
                        });
                        $("#roleList").html(roleListHtml.join(""));
                        form.render(null, 'addForm');
                    }
                }
            });
            /* 监听指定开关 */
            form.on('switch(status)', function (data) {
                if(this.checked){
                    $("#status").val(1);
                }else{
                    $("#status").val(0);
                }
            });

            //关闭窗口
            $("#close").click(function () {
                parent.layer.close(index);
            });
        };
    };

</script>